<?php
include 'dbconn.php';

function kingIcon($data){
	if($data[king]){
		echo "<img src='img/king.gif'>";
	}
}
$icon_coin="<img src='img/icon_gold.gif'>";
$icon_cash="<img src='img/cash.gif'>";

function _inven_type2str_($type){
	switch($type){
		case 0: return "body";
		case 1: return "hair";
		case 2: return "acc";
		case 3: return "mante";
	}
	return "";
}

function _getInvenImage_($type, $value){
	$str = _inven_type2str_($type);
	$value = ($value)?$value:"none";	
	return "<img src='img/".$str."/".$value.".png' width=32 height=32>";
	
}

function joinrefercode(){
	
	while(1){
		$refercode = createrefercode();
		$sql = "select my_refer from ebs_member where my_refer = '$refercode'";
		$res = mysql_query($sql);
		$data= mysql_num_rows($res);
		if(!$data){
			break;
		}
	}
	return $refercode;

}
function createrefercode(){

	$chars = range('a', 'z');
	$nums = range(0, 9);

	shuffle($chars);
	shuffle($nums);

	$rand_chars = implode(array_slice($chars, 0, 3));
	$rand_nums = implode(array_slice($nums, 0, 3));

	return $rand_chars.$rand_nums;
}
/*
function joinrefercode(){

	$sql = "select my_refer from ebs_member where no>0";
	$res = mysql_query($sql);
	$refers = array();
	while($data= mysql_fetch_array($res)){
		$refers[] = $data[my_refer];
	}

	while(1){
		
		$refercode = createrefercode();
		if(!in_array($refercode, $refer)){
			break;
		}
	}
	return $refercode;
}*/
?>